import merge_routers
import main
import datetime
import jaccard
import output

train_dates = [datetime.datetime(2014, 9, 10, 0, 0)]
for start_date in train_dates:
    end_date = start_date + datetime.timedelta(days = 1)
    [class_data, scan_data_binned, gps_data] = main.load_data(start_date, end_date)
    [merged_routers, merged_routers_count] = merge_routers.merge_routers_weighted(scan_data_binned, 100)
    jaccard_data = jaccard.calculate_jaccard_weighted(merged_routers, merged_routers_count, 1)
    
    output.plot_figure_1(merged_routers, 1, class_data, start_date, end_date, "merging_weighted" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + ".pdf", (8,6), True, jaccard_data, {})
        
        
        
#Merging of routers + JACCARD
# If router 1 always occurs when router 2 is present (= set of timebins when 1 is present is a subset of timebins when 2 is ready), then you can merge router 2 into router 1.
#Xperc = 100
#Xnum = 3
#merged_delta = 50
#X[merged_routers, merge_counted] = merge_routers_weighted_in_parts(scan_data_binned, perc, min(dates), max(dates), merged_delta)
#Calculate and plot Jacccard-index for most frequent routers
#Xjaccard_data2 = calculate_jaccard_weighted(merged_routers, merge_counted, delta)
#plot_jaccard(jaccard_data2, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins_merged_" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + ".pdf")
#plot_jaccard(jaccard_data2, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins_gt_merged_" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + ".pdf", True)
## Jaccard on scatter plot with GT
#Xplot_figure_1(merged_routers, min(dates), max(dates), "data_bin_" + str(delta) + "min_gt_small_jaccard_merged_" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + ".pdf", (8,6), True, jaccard_data2)
#plot_figure_1(merged_routers, min(dates), max(dates), "data_bin_" + str(delta) + "min_gt_small_jaccard_merged_" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + "_2.pdf", (8,6), True)
#for i in xrange(1, 4):
#    jaccard_diff_data = calculate_jaccard_difference(jaccard_data2, i)
#    plot_jaccard_diff(jaccard_diff_data, delta, min(dates), max(dates), "jaccard_diff_" + str(delta) + "min_bins" + str(i) + ".pdf", True)